 // Custom Class for Druid Healing in a PVP and PVE environment, from BGs to Raids
 // A collaboration of work with Sm0k3d and Glideroy, which was then modifed for druid by wildice. Some Code/ideas swiped from Apoc's singuler CC, GotWood, looked though some of the defaults.
// and cridit to Hazzard for anything he THINKS i may have copyed from him... All most all work in hear is by Sm0k3d and Glideroy, AoE selection code from apoc and then me.... so ya i don't know what thats about.
 // And a special thanks to all others who helped!

using System;
using System.Diagnostics;
using System.Drawing;
using Styx.Combat.CombatRoutine;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;



namespace RestorationIce
{
    partial class RestoIce
    {
        
        private WoWUnit lastCast=null;
        private WoWPlayer fallbacktank=null;
        private WoWPlayer tank;
        private WoWUnit Enemy;
        private Random rng;
        private WoWPlayer x;
        private WoWPlayer tar;
       // private WoWPlayer mtank;
        //From here for the gui
            private int SaveHP = 40; // HP to save Healer or Tank at over other targets.
            private int NS_HT = 25; // Nature's Swiftness Healing Touch Combo Health %
            private int NG_HT = 40; // Spam Heling touch when Nature's Grace buff is active and health is below % 
            private int TREEIT = 45; // Health % to pop tree form and entering into AoE Tree Logic
            private int Tree_num = 3; // Number of party/raid members required to be at treeit health inorder to pop tree form
            private bool Tranqtree = true; // cast tranq while in tree form?
            private int Tranq = 60; // health % to pop tranquility at
            private int Tranq_num = 3; // number of party/raid members required to be at tranq health inorder to pop tranq
            private int NGHT_PostAOE = 70;  // Nature's Grace Healing touch spam if someone is below this post aoe.
            private int CC_HT = 70; // Clearcast Healing touch
            private int CC_RG = 80; // Clearcast Regrowth Health
            private int Tank_HT = 65; // Tanks health % to use Healing Tocuh on them
            private int Tank_Rejuv = 90; // Tank health % to use Rejuvenation on them
            private int SM = 85; // Health % to use Swiftmend at
            private int WG_min_hp = 90; // Min hp to use Wild Growth
            private int WG_Num = 2; // Min number of raid/party members at WG_min_hp inorder to use Wild Growth
            private int Efflo_min_hp = 90; // Min hp to use Wild Efflorescence 
            private int Efflo_Num = 2; // Min number of raid/party members at Efflo_min_hp inorder to use Efflorescence
            private int Rejuv = 86; // min health to use Rejuvenation on party/raidmembers
            private int HT = 74; //Health % to use Healing Touch at
            private int Nourish = 90; // Health % tp use Nourish at if a hot is present
            private bool userebirth = true; //toggles weather or not to cast rebirth on the tank if he dies.
            private bool PVE_want_urgent_removecorruption = true;    //Do you want to RemoveCorruption critical stuff like Static Cling or Polymorph? (used)
            private bool PVP_want_urgent_removecorruption = true;    //Do you want to RemoveCorruption critical stuff like Static Cling or Polymorph? (used)
            private bool PVE_want_removecorruption = true;           //Do you want to RemoveCorruption debuff?
            private bool PVP_want_removecorruption = true;           //Do you want to RemoveCorruption debuff?
            private int PVE_max_healing_distance = 40;      //Ignore people more far away
            private bool PVE_wanna_BS = true;               //do we want to use Barkskin?
            private int PVE_do_not_heal_above = 98;         //at how much health we ignore people
            private int rest_if_mana_below = 60;            //if mana is this low and out of combat then drink
            private int use_mana_rec_trinket_every = 60;    //use the trinket to rec mana every 60 sec (for now only support Tyrande's Favorite Doll couse i have it :P)
            private int use_mana_rec_trinket_on_mana_below = 95;  //will use the trinket only if mana is below that
            private bool use_mana_potion = true;            //will use a mana potion? (not yet implemented)
            private int use_mana_potion_below = 20;         //% of mana where to use the potion
           // private bool PVE_wanna_everymanforhimself = true; //wanna use Every Man For Himself?
            private bool PVP_wanna_everymanforhimself = true;
            private int PVE_min_Innervate_mana = 70;
            private int PVP_min_Innervate_mana = 70;
            private bool PVE_wanna_DPS = false;
            private bool PVP_wanna_DPS = true;
            private bool PVE_wanna_Wrath = false;
          //  private bool PVP_wanna_Wrath = true;
            private bool PVE_wanna_buff = true;
            private bool PVP_wanna_buff = true;
            private bool PVE_wanna_mount = true;
            private bool PVP_wanna_mount = true;   
            private bool PVP_wanna_move_to_heal = false;
            private bool ARENA_wanna_move_to_heal = true;
            private bool PVE_wanna_move_to_heal = false;            
            private int PVP_do_not_heal_above = 95;
            private bool PVE_wanna_target = false;           //do you want the cc to target something if you do not have any target?
            private bool PVP_wanna_target = true;           //do you want the cc to target something if you do not have any target?
            private bool wanna_face = true;                 //do you want to face enemy when needed?

            // health monitering varibles
            public double myhealth = 0;
            public double tankhealth = 0;
            public double myhealthcentlosspersecond = 0;
            public double tankhealthcentlosspersecond = 0;
            public int counter = 0;
            public int counter2 = 0;
            double[] myhealthcalc = new double[5];
            double[] tankhealthcalc = new double[5];

        
        ////////////////////////////////////////////////////////////////////////////////////////////
        

        
        private bool isinterrumpable = false;
        private string lastBehaviour = null;
        private string actualBehaviour = null;
        private string usedBehaviour = null;
                

        private static Stopwatch sw = new Stopwatch();
        private static Stopwatch combatfrom = new Stopwatch();
        private static Stopwatch noncombatfrom = new Stopwatch();
        private static Stopwatch manapot = new Stopwatch();
        private static Stopwatch healthmon = new Stopwatch();
        public Stopwatch ng = new Stopwatch();

        private string version = "1.0";
        private string revision = "33";

        public override sealed string Name { get { return "RestoIce v " + version + " revision " + revision; } }

        public override WoWClass Class { get { return WoWClass.Druid; } }


        private static LocalPlayer Me { get { return ObjectManager.Me; } }

        public override void Initialize() 
        {
            slog(Color.Gold, "Hello Executor!\n I\'m RestoIce and i\'m here to assist you with keeping your friend's alive\n You're using RestoIce version {0} revision {1}", version,revision);            
        }       //if you need to run something just once do it here (will put up talent check in here)

        #region Combat

        public override void Combat()
        {
            if (!sw.IsRunning) sw.Start();
            /*
            if (Me == null) { return; }
            if (Me.Dead) { return; }
            if (!Me.IsValid) { return; }
            */
            if (unitcheck(Me) < 0)
            {
                slog(Color.Red, "We are on a loading schreen, or dead, or a ghost, CC is in PAUSE");
                return;
            }

            x = PartyCombat();
            tar = GetHealTarget();

            Behaviour();

            //if (Me != null && Me.IsValid && Me.IsAlive)
            if(unitcheck(Me)==1)
            {
                ObjectManager.Update();
                if (usedBehaviour == "Arena") 
                { 
                    ArenaCombat(); 
                }
                else if (usedBehaviour == "Dungeon") 
                { 
                    DungeonCombat(); 
                }
                else if (usedBehaviour == "Raid") 
                { 
                    RaidCombat(); 
                }
                else if (usedBehaviour == "Party or Raid") 
                { 
                    RafCombat(); 
                }
                else if (usedBehaviour == "Solo") 
                { 
                    SoloCombat(); 
                }
                else if (usedBehaviour == "World PVP") 
                { 
                    WorldPVPCombat(); 
                }
                else if (usedBehaviour == "Battleground")
                { 
                    BattlegroundCombat(); 
                }

            }
            return;
        }
        #endregion

        #region CC_Begin

        #endregion

        #region Pull

        public override void Pull() { }

        #endregion

        #region Pull Buffs

        public override bool NeedPullBuffs { get { Combat(); return false; } }

        public override void PullBuff() { }

        #endregion

        #region Pre Combat Buffs

        public override bool NeedPreCombatBuffs { get { Combat(); return false; } }

        public override void PreCombatBuff() { return; }

        #endregion

        #region Rest

        public override bool NeedRest { get { Combat(); return false; } }

        #endregion

        #region Combat Buffs

        public override bool NeedCombatBuffs { get { Combat(); return false; } }

        public override void CombatBuff() { }

        #endregion

        #region Heal

        public override bool NeedHeal { get { return false; } }

        public override void Heal() { }

        #endregion

        #region Falling

        public void HandleFalling() { }

        #endregion     

    }
}
